package com.emergency.service;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class RoadNetWebService { 
		//内网
	//static String ServerAddress="http://172.18.18.203:8199/phone/webService";	
	//static String ServerAddress="http://172.18.18.203:8887/phone/webService";	
	//static String ServerAddress="http://10.10.149.7:8887/phone/webService?wsdl";	
	static String ServerAddress="http://172.28.18.2:8887/phone/webService?wsdl";	
		//外网
		//static String ServerAddress="http://114.251.193.190:8887/phone/webService";
		//交通委网
		//static String ServerAddress="http://172.24.186.187:8887/phone/webService";
		public static String getFlyReportString(String functionName,String property) {//获得航班报表数据的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				rpc.addProperty("arg0", property);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = false;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
				
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}

		
		public static String getNearAirPortInfo(String functionName,String flno,String cnmc,String alcd,String startTime,String endTime,String status,String mvin) {//获得航班报表数据的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				
				rpc.addProperty("arg0", flno);
				rpc.addProperty("arg1", cnmc);
				rpc.addProperty("arg2", alcd);
				rpc.addProperty("arg3", startTime);
				rpc.addProperty("arg4", endTime);
				rpc.addProperty("arg5", status);
				rpc.addProperty("arg6", mvin);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = false;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
				
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
		
		public static String getFlyTextMoreString(String functionName) {//获得航班文字详细信息的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = true;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
		
		public static String getFlyTextString(String functionName) {//获得航班文字首页信息的webservice
			// WebService地址
		    final String NAMESPACE = "http://www.dhcc.com";
			String URL =ServerAddress;
			final String METHOD_NAME = functionName;
			String SOAP_ACTION = "http://www.dhcc.com/"+functionName;
			String returnString = null;
			try {
				
				SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
				SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
				envelope.bodyOut = rpc;
				envelope.dotNet = true;
				envelope.setOutputSoapObject(rpc);
				
				HttpTransportSE ht = new HttpTransportSE(URL);

				ht.debug = true;

				ht.call(SOAP_ACTION, envelope);
				
				SoapObject result = (SoapObject)envelope.bodyIn;
				
				returnString =  result.getProperty("return").toString();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return returnString;
		}
		
}
